<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<script>
	$(function() {
		$('#fitSerMgt_trainingMgt_datagrid').datagrid({
			url : 'trainingAction!getDatagrid.action',
			fitColumns : false,
			border : false,
			pagination : true,
			pageSize : 20,
			fit : true,
			singleSelect : true,
			rownumbers : true,
			idField : 'pkTraining',
			//sortName : 'name',
			columns : [ [ {
				field : 'pkTraining',
				title : '私教课程编号',
				width : 150,
				//hidden : true,
				align : 'center'
			}, {
				field : 'pkPlace',
				title : '场地编号',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'placeName',
				title : '场地名',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'pkCoach',
				title : '教练编号',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'coachName',
				title : '教练姓名',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'pkMember',
				title : '学员编号',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'memberName',
				title : '学员姓名',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'pkCourseDetail',
				title : '课程编号',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'courseDetailName',
				title : '课程名',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'beginDatetime',
				title : '课程开始时间',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'endDatetime',
				title : '课程结束时间',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'cdatetime',
				title : '创建时间',
				width : 150,
				sortable : true,
				align : 'center'
			}, {
				field : 'mdatetime',
				title : '最后修改时间',
				width : 150,
				sortable : true,
				align : 'center'
			} ] ],

			toolbar : [ {
				iconCls : 'icon-search',
				text : '查询',
				handler : function() {
					$('#fitSerMgt_trainingMgt_searchDialog').dialog('open');
				}
			}, '-', {
				iconCls : 'icon-add',
				text : '增加',
				handler : function() {
					$('#fitSerMgt_trainingMgt_addForm').form('clear');
					$('#fitSerMgt_trainingMgt_addDialog').dialog('open');
				}
			}, '-', {
				iconCls : 'icon-edit',
				text : '修改',
				handler : function() {
					trainingEdit();

				}
			}, '-', {
				iconCls : 'icon-remove',
				text : '删除',
				handler : function() {
					trainingRemove();
				}
			} ],
		});

		$('#fitSerMgt_trainingMgt_addForm').form({
			url : 'trainingAction!add.action',
			success : function(r) {
				var obj = jQuery.parseJSON(r);
				if (obj.success) {
					$('#fitSerMgt_trainingMgt_addDialog').dialog('close');
					$('#fitSerMgt_trainingMgt_datagrid').datagrid('load');
				}
				$.messager.alert({
					title : '提示',
					msg : obj.msg
				});
			}
		});

		$('#fitSerMgt_trainingMgt_editForm').form({
			url : 'trainingAction!edit.action',
			success : function(r) {
				var obj = jQuery.parseJSON(r);
				if (obj.success) {
					$('#fitSerMgt_trainingMgt_editDialog').dialog('close');
					$('#fitSerMgt_trainingMgt_datagrid').datagrid('load');
				}
				$.messager.alert({
					title : '提示',
					msg : obj.msg
				});
			}
		});
	});

	function trainingEdit() {
		var row = $('#fitSerMgt_trainingMgt_datagrid').datagrid('getSelected');
		if (row != null) {
			$('#fitSerMgt_trainingMgt_editDialog').dialog('open');
		} else {
			$.messager.alert({
				title : '提示',
				msg : '您未选中任何行！'
			});
		}
	};
	function trainingOpenEditDialog() {
		var row = $('#fitSerMgt_trainingMgt_datagrid').datagrid('getSelected');
		console.info(row);
		$('#fitSerMgt_trainingMgt_editForm').form('load', row);
	};

	function trainingRemove() {
		var row = $('#fitSerMgt_trainingMgt_datagrid').datagrid('getSelected');
		console.info(row);
		var id = null;
		if (row.pkTraining != null) {
			id = row.pkTraining;
			$.ajax({
				url : 'trainingAction!remove.action',
				data : {
					pkTraining : id
				},
				dataType : 'json',
				success : function(info) {
					$('#fitSerMgt_trainingMgt_datagrid').datagrid('reload');
					$('#fitSerMgt_trainingMgt_datagrid').datagrid('clearSelections');
					$.messager.alert({
						title : '提示',
						msg : info.msg
					});
				}
			});
		} else {
			$.messager.alert({
				title : '提示',
				msg : '您未选中任何行！'
			});
		}
	};
	function trainingSearchFun() {
		$('#fitSerMgt_trainingMgt_datagrid').datagrid('load', serializeObject($('#fitSerMgt_trainingMgt_searchForm')));
	};
	function trainingClearFun() {
		$('#fitSerMgt_trainingMgt_searchForm').form('clear');
		$('#fitSerMgt_trainingMgt_datagrid').datagrid('load', {});
	};
</script>

<div class="easyui-panel" data-options="border:false,fit:true">
	<div id="fitSerMgt_trainingMgt_datagrid_panel" class="easyui-panel" data-options="border:false,fit:true,">
		<table id="fitSerMgt_trainingMgt_datagrid"></table>
	</div>
</div>

<div id="fitSerMgt_trainingMgt_addDialog" class="easyui-dialog" style="width: 650px; height: 400px" data-options="iconCls:'icon-add',
		closed:true,
		minimizable:false,
		maximizable:false,
		draggable:false,
		title:' 增加',
		modal:true,
		buttons: [{text:'取消',
					iconCls:'icon-cancel',
					handler:function(){
						$('#fitSerMgt_trainingMgt_addDialog').dialog('close');
					}
				},{text:'增加',
					iconCls:'icon-add',
					handler:function(){
						$('#fitSerMgt_trainingMgt_addForm').submit();
					}
				}]
				">
	<form id="fitSerMgt_trainingMgt_addForm" style="margin: 3%">
		<table style="border-collapse:separate; border-spacing:15px;width:580px">
			<label>基本信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>课程编号</td>
				<td><input class="easyui-textbox" type="text" pkTraining="pkCoach" data-options="readonly:true"></input></td>

				<td>教练</td>
				<td><input class="easyui-combobox" type="text" name="pkCoach" panelHeight="120px" data-options="required:true,
				valueField:'pkCoach',
				textField:'name',
				editable:false,
				url:'coachAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>场地</td>
				<td><input class="easyui-combobox" type="text" name="pkPlace" panelHeight="120px" data-options="required:true,
				valueField:'pkPlace',
				textField:'name',
				editable:false,
				url:'placeAction!getComboBox.action'"></input></td>
				<td>课程</td>
				<td><input class="easyui-combobox" type="text" name="pkCourseDetail" panelHeight="120px" data-options="required:true,
				valueField:'pkCourseDetail',
				textField:'name',
				editable:false,
				url:'courseDetailAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>学员</td>
				<td><input class="easyui-combobox" type="text" name="pkMember" panelHeight="120px" data-options="required:true,
				valueField:'pkMember',
				textField:'name',
				editable:false,
				url:'memberAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>课程开始时间</td>
				<td><input class="easyui-datetimebox" type="text" name="beginDatetime" data-options="required:true"></input></td>
				<td>课程结束时间</td>
				<td><input class="easyui-datetimebox" type="text" name="endDatetime" data-options="required:true"></input></td>
			</tr>
		</table>
		<table style="margin-top: 15px;border-collapse:separate; border-spacing:15px;width:580px">
			<label>操作信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>创建时间</td>
				<td><input class="easyui-textbox" type="text" name="cdatetime" data-options="readonly:true"></input></td>
				<td>最后修改时间</td>
				<td><input class="easyui-textbox" type="text" name="mdatetime" data-options="readonly:true"></input></td>
			</tr>
		</table>
	</form>
</div>

<div id="fitSerMgt_trainingMgt_editDialog" class="easyui-dialog" style="width: 600px; height: 400px" data-options="iconCls:'edit-add',
		closed:true,
		minimizable:false,
		maximizable:false,
		draggable:false,
		title:' 修改',
		modal:true,
		buttons: [{text:' 取消',
					iconCls:'icon-cancel',
					handler:function(){
						$('#fitSerMgt_trainingMgt_editDialog').dialog('close');
					}
				},{text:' 修改 ',
					iconCls:'icon-edit',
					handler:function(){
						$('#fitSerMgt_trainingMgt_editForm').submit();
					}
				}],
				onOpen:function(){
					trainingOpenEditDialog();
				}
				">
	<form id="fitSerMgt_trainingMgt_editForm" style="margin: 3%">
		<table style="border-collapse:separate; border-spacing:15px;width:580px">
			<label>基本信息</label>
			<hr style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>私教课程编号</td>
				<td><input class="easyui-textbox" type="text" name="pkTraining" data-options="readonly:true"></input></td>
			</tr>
			<tr>
				<td>教练</td>
				<td><input class="easyui-combobox" type="text" name="pkCoach" panelHeight="120px" data-options="required:true,
				valueField:'pkCoach',
				textField:'name',
				editable:false,
				url:'coachAction!getComboBox.action'"></input></td>
				<td>场地</td>
				<td><input class="easyui-combobox" type="text" name="pkPlace" panelHeight="120px" data-options="required:true,
				valueField:'pkPlace',
				textField:'name',
				editable:false,
				url:'placeAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>课程</td>
				<td><input class="easyui-combobox" type="text" name="pkCourseDetail" panelHeight="120px" data-options="required:true,
				valueField:'pkCourseDetail',
				textField:'name',
				editable:false,
				url:'courseDetailAction!getComboBox.action'"></input></td>
				<td>学员</td>
				<td><input class="easyui-combobox" type="text" name="pkMember" panelHeight="120px" data-options="required:true,
				valueField:'pkMember',
				textField:'name',
				editable:false,
				url:'memberAction!getComboBox.action'"></input></td>
			</tr>
			<tr>
				<td>课程开始时间</td>
				<td><input class="easyui-datetimebox" type="text" name="beginDatetime" data-options="required:true"></input></td>
				<td>课程结束时间</td>
				<td><input class="easyui-datetimebox" type="text" name="endDatetime" data-options="required:true"></input></td>
			</tr>
		</table>
		<table style="margin-top: 15px;border-collapse:separate; border-spacing:15px;width:580px">
			<label>操作信息</label>
			<hr s style="height: 1px; border: none; border-top: 1px solid #D8E6E7;" />
			<tr>
				<td>创建时间</td>
				<td><input class="easyui-textbox" type="text" name="cdatetime" data-options="readonly:true"></input></td>
				<td>最后修改时间</td>
				<td><input class="easyui-textbox" type="text" name="mdatetime" data-options="readonly:true"></input></td>
			</tr>
		</table>
	</form>
</div>


<div id="fitSerMgt_trainingMgt_searchDialog" class="easyui-dialog" title="查询" style="width: 600px; height: 300px" data-options="iconCls:'icon-search',modal:true,closed:true,collapsible:false,minimizable:false,maximizable:false,
		buttons: [{text:'重置查询结果',
					iconCls:'icon-reload',
					handler:function(){
						trainingClearFun();
						$('#fitSerMgt_trainingMgt_searchDialog').dialog('close');
					}
				},
		{text:'重置查询条件',
					iconCls:'icon-redo',
					handler:function(){
						$('#fitSerMgt_trainingMgt_searchForm').form('clear');
					}
				},{text:'查询',
					iconCls:'icon-search',
					handler:function(){	
						trainingSearchFun();
						$('#fitSerMgt_trainingMgt_searchDialog').dialog('close');
					}
				}]">

	<form id="fitSerMgt_trainingMgt_searchForm" style="margin: 5%">
		<table style="border-collapse:separate; border-spacing:15px;">
			<tr>
				<td>教练名</td>
				<td><input class="easyui-textbox" type="text" name="coachName" data-options=""></input></td>
			</tr>
			<tr>
				<td>课程开始日期</td>
				<td><input class="easyui-datebox" type="text" name="beginDatetime" data-options=""></input></td>
				<td>课程结束日期</td>
				<td><input class="easyui-datebox" type="text" name="endDatetime" data-options=""></input></td>
			</tr>

			<!--  <tr>
				<td>员工编号</td>
				<td><input class="easyui-textbox" type="text" name="pkTraining" data-options=""></input></td>
			</tr>-->

		</table>
	</form>
</div>
</table>